package compiler;

import java.util.HashMap;
import java.util.Map;

public enum Words
{
	FOR("FOR", 282),
	ROF("ROF", 283),
	IF("IF", 284),
	THEN("THEN", 285),
	DO("DO", 286),
	ELSE("ELSE", 287),
	FI("FI", 288),
	VAR("VAR", 289),
	ENDVAR("ENDVAR", 290),
	INT("INT", 291),
	FLOAT("FLOAT", 292),
	DOUBLE("DOUBLE", 293),
	LONG("LONG", 294),
	STRING("STRING", 295),
	NOT("NOT", 296),
	AND("AND", 297),
	OR("OR", 298),
	FILTERC("FILTERC", 299),
	WPRINT("WPRINT", 300);
	
	public final static Integer OPSUMA=257;
	public final static Integer OPRESTA=258;
	public final static Integer OPMULT=259;
	public final static Integer OPDIV=260;
	public final static Integer CONCAT=261;
	public final static Integer OPASIGN=262;
	public final static Integer MAYOR=263;
	public final static Integer MENOR=264;
	public final static Integer MAYORIGUAL=265;
	public final static Integer MENORIGUAL=266;
	public final static Integer IGUALIGUAL=267;
	public final static Integer DISTINTO=268;
	public final static Integer ID=269;
	public final static Integer CTESTRING=270;
	public final static Integer CTE=271;
	public final static Integer PYC=272;
	public final static Integer DOSPUNTOS=273;
	public final static Integer COMA=274;
	public final static Integer INIPAREN=275;
	public final static Integer FINPAREN=276;
	public final static Integer INICOR=277;
	public final static Integer FINCOR=278;
	public final static Integer GUIONBAJO=279;
	public final static Integer INILLAVE=280;
	public final static Integer FINLLAVE=281;
	
	private final String text;
	private final Integer numero;
	private static Map<String, Words> stringMap = new HashMap<String, Words>();
	
	Words(final String text, Integer i)
	{
		this.text = text;
		this.numero = i;
	}

	public static Words getWords(String key)
	{
		return stringMap.get(key);
	}
	
	public static Words buscar(String input)
	{
	    for(Words v : values())
	    {
	        if(v.toString().equals(input.toUpperCase()))
	        	return v;
	    }
	    return null;
	}
	
	public static Words buscar(int input)
	{
	    for(Words v : values())
	    {
	    	System.out.println(">>>>  Busca "+v+" con "+input);
	        if(v.equals(input))
	        	return v;
	    }
	    return null;
	}
	
	@Override
	public String toString()
	{
		return this.text;
	}
	
	public Integer getNumero()
	{
		return numero;
	}
}
